import React from 'react';
import SwitchDateStyle from './SwitchDate.less';
import cx from 'classnames';

export default class SwitchDate extends React.Component {
  static propTypes = {
    name: React.PropTypes.string,
  };

  constructor(props) {
    super(props);
  }
  state = {
    toggle:false
  }
  handleClick = (params) =>{
  	let { onSelectDate } = this.props;
    if (params=='sevenDays'){
      this.setState({
        toggle:true
      })
    } else {
      this.setState({
        toggle:false
      })
    }
  	onSelectDate&&onSelectDate(params) 
  }
  render() {
    let { toggle } = this.state;
    let clazz = cx('first', {'active': toggle});
    let claxx = cx('second', {'active': !toggle});
    return (
    	<div className={SwitchDateStyle.switchDate}>
        <span className={clazz} onClick={()=>this.handleClick('sevenDays')}>近7天</span>
        <span className={claxx} onClick={()=>this.handleClick('thirtyDays')}>近30天</span>
        </div>
    );
  }
}
